<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>申请书编辑</title>
<script type="text/javascript" src="${res}/js/jquery/jquery.form.js"></script>
<script type="text/javascript"
	src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res}/js/validate/irisvalidator.js"></script>
<script type="text/javascript" src="${res}/js/keyword/keywordtips.js"></script>
<script type="text/javascript" src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>
<style>
textarea {
	overflow: auto;
}
</style>

<script type="text/javascript">
function validateByTabRow1(obj, title, rowNum) {
	if ((obj.find("tr").length - 3) < rowNum)
		irisValaddMsg(messageTip.rowNum.replace("[name]", title).replace(
				"[num]", rowNum));
	obj.find("tr").each(
			function(index) {

				if (index >= 3) {
					rtitle = messageTip.rowIndex.replace("[name]", title)
							.replace("[index]", index - 2);
					validate($(this), rtitle);
				}
			});
}
	$(function() {
		queryflex();
	});
	/**
	 * 申请书提交方法
	 */

	var ctxpath = "${ctx}";
	var prcWin = new progressWin("${res}");//初始化遮罩层
	/**
	 * 页面初始化方法 所有的都定义在里面
	 */
	$(document).ready(
			function() {
				$("#wbox1").click(function() {
					check("check");

				});

				$("#wbox2").click(function() {

					check("check");

				});

				initControl();

				$("table.t_css").not("[id='finances']").not(
						"[id='checkbox_table_']").not("[id='budgetsMsg2']")
						.each(function() {
							$(this).find("tr:even").addClass("li_1");
							$(this).find("tr:odd").addClass("li_2");
						});
				$("table").addClass("table01");
				$("#checkbox_table_").removeClass("table01");
				$("#feaReport_upload").removeClass("table01");
				$('div').find("[id^='checkbox_dyn_']").find("tr").removeClass(
						"li_1").removeClass("li_2");
				$('div').find("[id^='checkbox_dyn_']").find("td").css("border",
						'0px solid');

				//updatePdfNotes();
				window.setInterval("checkPdfStatus()", "10000");//检验申请书的pdf
			});

	$(document).ready(function() {
		fileInit("feaReport_upload","PDF");
	/* 	fileInit("prpContent_upload","JPG,PDF,TIFF,XLS,DOC,WPS",null,"{'JPG':'51200','PDF':'51200','TIFF':'51200','XLS':'51200','DOC':'51200','WPS':'51200'}");	
	 */ 
		fileInit("prpContent_upload","JPG,PDF,DOC,DOCX,WPS",null,"");	
	 //fileInitAttach("attachAdd", "JPG,PDF", null, 20, "{'JPG':'3072','PDF':'3072'}");
		$("#prpContent_upload").find(".file").hide();//隐藏文本框
	});

	
	
	
	$(document).ready(function() {
		$("#org").attr("disabled", "true");
		initDepartForComplete("org");
		initControl();
	});

	/**
	 * 申报日期默认为当前日期
	 */
	$(document).ready(function() {

		var nowDate = '${sercverSysDate1}';
		if ($("#submit_date").val() == "") {
			$("#submit_date").val(nowDate);
		}

	});

	/**
	 * 填写检查
	 */
	function check(type) {
		setTotalAmt();
		validate($("#basicInfo1"), "项目基本情況-->基本信息");
		validate($("#lxr"), "项目基本情況-->联系人信息");
		validate($("#ftable"), "建设情況");
		validate($("#ftable11"), "建设情況");
		validate($("#ftabl"), "建设情況");
		validateByTabRow($("#committee"),"建设情況-->管理委员会成员",1);
		validateByTabRow($("#learning"),"建设情況-->学术（工程技术）委员会成员",1);
		validate($("#basicInfo6"), "研究开发情况-->项目承担情况");	
		var num = $("#num").val();
		 if(num>0)
		validateByTabRow($("#completedproject"),"研究开发情况-->已完成项目",1);
		var numbrt = $("#number").val();
		if(numbrt>0)
		validateByTabRow($("#currentresearch"),"研究开发情况-->在研项目",1);
		var sum_entrust = parseInt($("#completed_project_entrust").val())+parseInt($("#current_research_project_entrust").val());
		if(sum_entrust>0)
		validateByTabRow($("#entrust"),"研究开发情况-->承担的横向委托项目信息表",1);
		if(sum_entrust==0)
		validateByTabRow($("#entrust"),"研究开发情况-->承担的横向委托项目信息表");
		var sum_optional = parseInt($("#completed_project_optional").val())+parseInt($("#current_research_project_optional").val());
		if(sum_optional>0)
		validateByTabRow($("#optional"),"研究开发情况-->自选项目信息表",1);
		if(sum_optional==0)
		validateByTabRow($("#optional"),"研究开发情况-->自选项目信息表");
		validate($("#awards"),"取得的科技成果和获奖情况-->获奖情况");
		var sum_award = parseInt($("#technological_invention_total").val())+parseInt($("#natural_science_total").val())+parseInt($("#progress_total").val())+parseInt($("#provincial_total").val());
		if(sum_award>0)
		validateByTabRow($("#award"),"取得的科技成果和获奖情况-->成果展示",1);
		validate($("#publish_thesis"),"取得的科技成果和获奖情况-->发表论文、著作情况");
		if((parseInt($("#fblw").val())+parseInt($("#cbzz").val()))>0)
		validateByTabRow($("#publish"),"取得的科技成果和获奖情况-->发表论文、著作详细情况",1);
		validate($("#patent"),"取得的科技成果和获奖情况-->专利情况");
		if($("#grant_patent_total").val()>0)
		validateByTabRow($("#patentdetail"),"取得的科技成果和获奖情况-->授权专利详细情况",1);
		validate($("#standard"),"取得的科技成果和获奖情况-->技术标准制定情况-->制定标准");
		if($("#standard_total").val()>0)
		validateByTabRow($("#standardetail"),"取得的科技成果和获奖情况-->制定标准详细情况",1);
		validateByTabRow($("#pservice"),"成果转化情况-->平台成果转化、转移、推广与服务情况表");
		validate($("#ftable33"), "成果转化情况");
		validate($("#facilities"), "设施设备建设和人员情况-->平台现有设施条件及开放情况");
		if($("#quantity").val()>0)
		validateByTabRow($("#majorequipment"),"设施设备建设和人员情况-->主要设备（50万元以上设备）",1);
		validate($("#constructionperson"), "设施设备建设和人员情况-->平台人员情况");
		if($("#center_staff_number").val()>0)
		validateByTabRow($("#person"),"设施设备建设和人员情况-->人员详细信息",1);
		validate($("#open_service"), "设施设备建设和人员情况-->开放服务情况");
		validate($("#culture"), "设施设备建设和人员情况-->培养人才和培训人员情况");
		validate($("#academic_exchange"), "设施设备建设和人员情况-->学术交流情况");
		validate($("#meeting"),"设施设备建设和人员情况-->学术（展销）会议信息");/*  */
		validate($("#performances"), "合作以及管理-->合作单位情况");
		var sum_cooperation = parseInt($("#domestic_junior_cooperation").val())+parseInt($("#domestic_research_cooperation").val())+parseInt($("#domestic_enterprise_cooperation").val())+
		 parseInt($("#abroad_junior_cooperation").val())+parseInt($("#abroad_research_cooperation").val())+parseInt($("#abroad_enterprise_cooperation").val());
		if(sum_cooperation>0)
		validateByTabRow($("#cooperativeunit"),"合作以及管理-->合作单位信息",1);
		validate($("#fundinvestment"), "经费预算与发展规划-->经费投入情况");
		validate($("#funduse"), "经费预算与发展规划-->经费使用情况");
		validate($("#ftable14"), "经费预算与发展规划");
		validate($("#ftable16"), "经费预算与发展规划");
		validate($("#ftable17"), "经费预算与发展规划");/*  */
		validateByTabRow($("#assessment"),"建设计划-->建设计划及年度考核指标",1);
		prp_attach();
		if (!valResult()) {
			irisValShowMsg($("#wbox1"));
			return false;
		}
		if (type == "check") {
			showBox($("#wbox1"), "300px", "200px", "检查通过", "1:所有检查全部合格");
		}
		return true;
	}

	function setTotalAmt() {
		$('#request_amt').val($("#total_invest_0").val());
	}

	function initTreeValueExt(treeId, treeNode) {

		if (!(treeNode && (treeNode.level > 0 || !treeNode.isParent))) {
			scmWarn($("#" + treeId).attr("label")
					+ messageTip.researchAreaInvalidDisciplineCode);
			if (treeNode.level == 0) {
				$("#" + treeId).val("");
				$("#" + treeId).parents("td").find(
						"[name$='" + treeId + "_code'],[id$='" + treeId
								+ "_code']").val("");
				$("#" + treeId).parents("td").find(
						"[name$='" + treeId + "_value'],[id$='" + treeId
								+ "_value']").val("");
				$("#" + treeId).parents("td").find(
						"[name$='" + treeId + "_name'],[id$='" + treeId
								+ "_name']").val("");
			}

			return false;
		}

		var str = treeNode.name;
		var obj = treeNode.parentNode;
		while (obj != null) {
			obj = obj.parentNode;
		}

		$("#" + treeId).parents("td").find(
				"[name$='" + treeId + "_code'],[id$='" + treeId + "_code']")
				.val(treeNode.id);
		$("#" + treeId).parents("td").find(
				"[name$='" + treeId + "_value'],[id$='" + treeId + "_value']")
				.val(treeNode.id);
		$("#" + treeId).parents("td").find(
				"[name$='" + treeId + "_name'],[id$='" + treeId + "_name']")
				.val(str);

	}
	
</script>
<style>
textarea {
	overflow: auto;
}
</style>
</head>
<body>

	<c:set var="xmlstr" value="${xmlData}" scope="request" />
	<x:parse xml="${xmlstr}" var="xmlData" scope="request" />
	<input type="hidden" id="childDiv" class="thickbox" />
	<input type="hidden" id="filePath"
		value="${ctx}/file/ajax-filedownload?fileCode=" />
	<input type="hidden" id="menuId" value="${param.menuId}" />
	<input type="hidden" id="sysDate" value="${sercverSysDate}" />

	<div id="showMessage"></div>
	<div id="content">

		<cpt:helpTips key="prpedit" id="prpEditTips"></cpt:helpTips>
		<div class="clear_h15"></div>
		<div class="word_box" id="mainDiv">
			<jsp:include page="./prpeditmain_public_first.jsp"><jsp:param
					value="${xmlstr}" name="xmlstr" /></jsp:include>
			<div class="bar_b">
				<input type="hidden" id="pdfStatus" value="${pdfStatus}" /> <span
					class="right">版本号：<span name="proposal/prp_version"
					id="prp_version"><x:out
							select="$xmlData/data/proposal/prp_version" /></span></span>
			</div>
			<form method="post" id="mainForm">
				<input type="hidden" value="${grantCode}" id="grantCode"
					name="grantCode"> <input type="hidden" value="${posCode}"
					id="posCode" name="posCode"> <input type="hidden"
					value="<iris:des3 code="${posCode}"></iris:des3>" id="posCodeDes"
					name="posCodeDes"> <input type="hidden"
					value="<iris:des3 code="${fbl.pdfCode}"></iris:des3>"
					id="pdfCodeDes" name="pdfCodeDes"> <input type="hidden"
					value="${xmlData}" id="xmlData" name="xmlData"> <input
					type="hidden" value="${fbl.pdfCode}" id="pdfCode" name="pdfCode">
				<input type="hidden" value="${flag_shizhi}" id="flag_shizhi"
					name="proposal/flag_shizhi">
			</form>
			<div class="word_title">
				<c:set var="statYear">${statYear}</c:set>
				<c:if test="${empty statYear}">
					<c:set var="statYear">
						<x:out select="$xmlData/data/proposal/stat_year" />
					</c:set>
				</c:if>
				<input type="hidden" name="proposal/stat_year" value="${statYear}">
				<span name="proposal/grant_name"><x:out
						select="$xmlData/data/proposal/grant_name" /></span>-项目申请书 (<span
					name="proposal/stat_year">${statYear}</span>年)<br />
					(<x:out select="$xmlData/data/proposal/sub_grant_name" />)
				<c:set var="formCode">
					<x:out select="$xmlData/data/proposal/form_code" />
				</c:set>
				<input type="hidden" name="organizations/organization[0]@submit_org"
					value="1"> <input type="hidden"
					name="organizations/organization[0]/nature_value"
					value="<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" />">

				<c:set var="nature_value">
					<x:out
						select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" />
				</c:set>
				<c:if test="${empty formCode}">
					<c:set var="formCode" value="${param.formCode}"></c:set>
				</c:if>
				<input type="hidden" name="proposal/form_code" value="${formCode}" />
				<input type="hidden" name="proposal/year" value="${year}" />
				<!-- 公用的配置界面 -->
				<jsp:include page="./prpeditmain_public.jsp"></jsp:include>
			</div>
			<div id="tabnav">
				<ul>
					<li class="down" id="tab0" onclick="changeTab(this.id)"><a href="###"><span>编写说明</span></a></li>
					<li id="tab1" onclick="changeTab(this.id)"><a href="###"><span>项目基本情況</span></a></li>
					<li id="tab2" onclick="changeTab(this.id)"><a href="###"><span>建设情况</span></a></li>
					<li id="tab3" onclick="changeTab(this.id)"><a href="###"><span>研究开发情况</span></a>
					</li>
					<li id="tab4" onclick="changeTab(this.id)"><a href="###"><span>取得的科技成果和获奖情况</span></a>
					</li>
					<li id="tab5" onclick="changeTab(this.id)"><a href="###"><span>成果转化情况</span></a>
					</li>
					<li id="tab6" onclick="changeTab(this.id)"><a href="###"><span>设施设备建设和人员情况</span></a>
					</li>
					
					
				</ul>
			</div>
			<div id="tabnav">
				<ul>
				<li id="tab7" onclick="changeTab(this.id)"><a href="###"><span>合作以及管理</span></a>
					</li>
				<li id="tab8" onclick="changeTab(this.id)"><a href="###"><span>经费预算与发展规划</span></a>
					</li>
					<li id="tab9" onclick="changeTab(this.id)"><a href="###"><span>建设计划</span></a>
					<li id="tab10" onclick="changeTab(this.id)"><a href="###"><span>附件清单</span></a>
				</li>
				</ul>
			</div>
			<!-- 编写说明 -->
			<div class="tab_box" id="fragment-tab0">
				<jsp:include page="../instruction/prpEditGuide_cxptjs_2016.jsp"></jsp:include>
			</div>
			<!-- 项目基本情況 -->
			<div class="tab_box" id="fragment-tab1"  style="display: none">
				<jsp:include page="../info/prpInfoEdit_cxptjs_2016.jsp">
				 <jsp:param value="${statYear }" name="statYear" />
				</jsp:include>
			</div>
			<!-- 建设情况 -->
			<div class="tab_box" id="fragment-tab2"  style="display: none">
				<jsp:include page="../knowledge/prpknowledge_cxptjs_2016.jsp"></jsp:include>
			</div>
			<!-- 研究开发情况 -->
			 <div class="tab_box" id="fragment-tab3" style="display: none">
				<jsp:include page="../psn/prpzhpsn_cxptjs_2016.jsp"></jsp:include>
			</div>
			<!-- 取得的科技成果和获奖情况 -->
			<div class="tab_box" id="fragment-tab4" style="display: none">
				<jsp:include page="../goal/prpgoaledit_cxptjs_2016.jsp"></jsp:include>
			</div>
			<!-- 成果转化情况 -->
			<div class="tab_box" id="fragment-tab5" style="display: none">
				<jsp:include page="../fund/prpfundedit_cxptjs_2016.jsp"></jsp:include>
			</div>
			<!-- 设施设备建设和人员情况 -->
			<div class="tab_box" id="fragment-tab6" style="display: none">
				<jsp:include page="../milestone/prpmilestoneedit_cxptjs_2016.jsp"></jsp:include>
			</div>
			<!-- 合作以及管理 -->
			<div class="tab_box" id="fragment-tab7" style="display: none">
				<jsp:include page="../performance/prpperformanceedit_cxptjs_2016.jsp"></jsp:include>
			</div>
			<!-- 经费预算与发展规划 -->
			<div class="tab_box" id="fragment-tab8" style="display: none">
				<jsp:include page="../product/prpproduct_cxptjs_2016.jsp"></jsp:include>
			</div>
			<!-- 建设计划 -->
			<div class="tab_box" id="fragment-tab9" style="display: none">
				<jsp:include page="../content/prpContentEdit_cxptjs_2016.jsp"></jsp:include>
			</div>
			<!-- 附件清单 -->
			<div class="tab_box" id="fragment-tab10" style="display: none">
				<jsp:include page="../attach/prpAttachEdit_cxptjs_2016.jsp">
				<jsp:param value="${xmlstr}" name="xmlstr" /></jsp:include>
			</div>
			<jsp:include page="./prpeditmain_public_last.jsp"><jsp:param
					value="${xmlstr}" name="xmlstr" /></jsp:include>
		
		</div>
		<div class="clear_h15"></div>
	</div>
</body>

</html>